#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
//http://oj33.cn/contest.php?cid=1075
//https://blog.csdn.net/qq_37482202/article/details/89513877
struct node
{
	int x; int y;

}f[301][301],k1,k2;
node find(node k)
{
	if (f[k.x][k.y].x== k.x&&f[k.x][k.y].y==k.y)
	{
		return k;
	}
	f[k.x][k.y] = find(f[k.x][k.y]);
	return f[k.x][k.y];
}
int main()
{
	int x, y;char c;
	int n, m;
	cin >> n >> m;
	for(int i=1;i<=n;i++)
		for (int j = 1; j <= n; j++)
		{
			f[i][j].x = i;
			f[i][j].y = j;
	}
	for (int i = 1; i <= m; i++)
	{
		cin >> x >> y >> c;
		if (c == 'D')
		{
			k1=find(f[x][y]);
			k2=find(f[x+1][y]);
		}
		if (c == 'R')
		{
			k1 = find(f[x][y]);
			k2 = find(f[x][y + 1]);
		}
		if (k1.x == k2.x && k1.y == k2.y)
		{
			cout << i << endl;
			return 0;
		}
		else
		
			f[k1.x][k1.y] = k2;
	
	}cout << "draw" << endl;
	return 0;
}